package cassys.domain.classManagement;

import cassys.domain.assessment.AssessmentGroup;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author Thurien
 */
public class Student  implements Serializable {

    private long studentId;
    private boolean selected;
    private String name;
    private Set<ClassRegistration> classRegistrations;
    private Set<AssessmentGroup> assessmentGroups;

    public Student() {
        classRegistrations = new HashSet<ClassRegistration>();
        assessmentGroups = new HashSet<AssessmentGroup>();
    }

    public Student(String name) {
        this();
        this.name = name;

    }

    public void signUpAssessmentGroup(AssessmentGroup assessmentGroup) {
        this.assessmentGroups.add(assessmentGroup);
    }

    public void signUpClassGroup(ClassRegistration classRegistration) {

        this.classRegistrations.add(classRegistration);
    }

    public boolean isMemberOf(ClassGroup classGroup) {
        for (ClassRegistration classRegistration : classRegistrations) {
            if (classRegistration.getClassGroup().equals(classGroup) && classRegistration.getStatus() ==ClassRegistrationStatus.active ) {
                return true;
            }
        }
        return false;
    }

    public boolean isMemberOf(AssessmentGroup assessmentGroup) {
        return this.assessmentGroups.contains(assessmentGroup);
    }

    //withdraw transaction must be invoke through the class group
    protected void withdraw(ClassGroup classGroup) {
        this.classRegistrations.remove(classGroup);
    }

    public long getStudentId() {
        return studentId;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }
    public void setStudentId(long studentId) {
        this.studentId = studentId;
    } 
    
public void setName(String name) {
        this.name = name;
    }
    
}
